﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Reflection;
using System.Configuration;
using System.Security.Cryptography;

namespace CNdotnet.Ezsocio.Core.Security
{
    public static class CryptoFactory
    {
        static readonly string securityAss = ConfigurationManager.AppSettings["CNdotnet.Ezsocio.SecurityAssembly"];
        static readonly string symmetricAlgo = ConfigurationManager.AppSettings["CNdotnet.Ezsocio.SymmetricAlgorithmType"];

        public static ICryptographyProvider SymmetricCreate()
        {
            ISymmetricAlgorithmCreate creator = (ISymmetricAlgorithmCreate)Assembly.Load(securityAss).CreateInstance(symmetricAlgo);
            return creator.Create();
        }

        public static ICryptographyProvider HashCreate()
        {
            return new HashAlgorithmProvider();
        }

        public static ICryptographyProvider NonCrptoCreate()
        {
            return new NonCryptoProvider();
        }
    }
}
